<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class DataRPDController extends BaseController {
    /*
     * Konstruktor
     */

    public function __construct($registry) {
        parent::__construct($registry);
    }

    /*
     * Index
     */

    public function rekapRPDMinggu() {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdkanwil'] != '') {
                $filter[$no++] = "KDKANWIL = '" . $_POST['kdkanwil'] . "'";
                $d_kanwil = new DataUser($this->registry);
                $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$_POST['kdkanwil']);
                $this->view->d_kanwil = $_POST['kdkanwil'];
            }
            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KDKPPN = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
                $this->view->d_kd_kppn = $_POST['kdkppn'];
            }
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kdsatker = $_POST['kdsatker'];
            }
            if ($_POST['akun'] != '') {
                $filter[$no++] = "AKUN = '" . $_POST['akun'] . "'";
                $this->view->d_akun = $_POST['akun'];
            }
            if (Session::get('role') == SATKER) {
                $filter[$no++] = " kdsatker = '" . Session::get('kd_satker') . "'";
                $this->view->d_satker = Session::get('kd_satker');
            }
			
            $this->view->data = $d_rpd->get_page1($filter);
        }

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpd1');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDHari($bulan=null,$minggu=null,$kanwil=null,$kppn=null,$satker=null,$akun=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }

        //filter url
        if ($bulan != 'SEMUA') {
            $filter[$no++] = "BULAN = '" . $bulan . "'";
            $this->view->d_bulan = $bulan;
        }
        if ($minggu != 'SEMUA') {
            $filter[$no++] = "MINGGU = '" . $minggu . "'";
            $this->view->d_minggu = $minggu;
        }
        if ($kanwil != 'SEMUA') {
            $filter[$no++] = "KDKANWIL = '" . $kanwil . "'";
            $d_kanwil = new DataUser($this->registry);
            $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$kanwil);
            $this->view->d_kanwil = $kanwil;
        }
        if ($kppn != 'SEMUA') {
            $filter[$no++] = "KDKPPN = '" . $kppn . "'";
            $d_kppn = new DataUser($this->registry);
            $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($kppn);
            $this->view->d_kd_kppn = $kppn;
        }
        if ($satker != 'SEMUA') {
            $filter[$no++] = "KDSATKER = '" . $satker . "'";
            $this->view->d_kdsatker = $satker;
        }
        if ($akun != 'SEMUA') {
            $filter[$no++] = "AKUN = '" . $akun . "'";
            $this->view->d_akun = $akun;
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " kdsatker = '" . Session::get('kd_satker') . "'";
            $this->view->d_satker = Session::get('kd_satker');
        }
			
            $this->view->data = $d_rpd->get_page2($filter,$minggu);

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpd2');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDMingguKPPN() {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdkanwil'] != '') {
                $filter[$no++] = "KDKANWIL = '" . $_POST['kdkanwil'] . "'";
                $d_kanwil = new DataUser($this->registry);
                $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$_POST['kdkanwil']);
                $this->view->d_kanwil = $_POST['kdkanwil'];
            }
            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KDKPPN = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
                $this->view->d_kd_kppn = $_POST['kdkppn'];
            }
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kdsatker = $_POST['kdsatker'];
            }
            if ($_POST['akun'] != '') {
                $filter[$no++] = "AKUN = '" . $_POST['akun'] . "'";
                $this->view->d_akun = $_POST['akun'];
            }
            if (Session::get('role') == SATKER) {
                $filter[$no++] = " kdsatker = '" . Session::get('kd_satker') . "'";
                $this->view->d_satker = Session::get('kd_satker');
            }
			
            $this->view->data = $d_rpd->get_page3($filter);
        }

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpd3');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDHariKPPN($bulan=null,$minggu=null,$kanwil=null,$kppn=null,$satker=null,$akun=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }

        //filter url
        if ($bulan != 'SEMUA') {
            $filter[$no++] = "BULAN = '" . $bulan . "'";
            $this->view->d_bulan = $bulan;
        }
        if ($minggu != 'SEMUA') {
            $filter[$no++] = "MINGGU = '" . $minggu . "'";
            $this->view->d_minggu = $minggu;
        }
        if ($kanwil != 'SEMUA') {
            $filter[$no++] = "KDKANWIL = '" . $kanwil . "'";
            $d_kanwil = new DataUser($this->registry);
            $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$kanwil);
            $this->view->d_kanwil = $kanwil;
        }
        if ($kppn != 'SEMUA') {
            $filter[$no++] = "KDKPPN = '" . $kppn . "'";
            $d_kppn = new DataUser($this->registry);
            $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($kppn);
            $this->view->d_kd_kppn = $kppn;
        }
        if ($satker != 'SEMUA') {
            $filter[$no++] = "KDSATKER = '" . $satker . "'";
            $this->view->d_kdsatker = $satker;
        }
        if ($akun != 'SEMUA') {
            $filter[$no++] = "AKUN = '" . $akun . "'";
            $this->view->d_akun = $akun;
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " kdsatker = '" . Session::get('kd_satker') . "'";
            $this->view->d_satker = Session::get('kd_satker');
        }
			
            $this->view->data = $d_rpd->get_page4($filter,$minggu);

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpd4');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDSatker($bulan=null,$kanwil=null,$kppn=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }
        if(is_null($bulan)){$bulan="SEMUA";}
        if(is_null($kanwil)){$kanwil="SEMUA";}
        if(is_null($kppn)){$kppn="SEMUA";}

        //filter url
        if ($bulan != 'SEMUA') {
            $filter[$no++] = "BULAN = '" . $bulan . "'";
            $this->view->d_bulan = $bulan;
        }
        if ($kanwil != 'SEMUA') {
            $filter[$no++] = "KDKANWIL = '" . $kanwil . "'";
            $d_kanwil = new DataUser($this->registry);
            $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$kanwil);
            $this->view->d_kanwil = $kanwil;
        }
        if ($kppn != 'SEMUA') {
            $filter[$no++] = "KDKPPN = '" . $kppn . "'";
            $d_kppn = new DataUser($this->registry);
            $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($kppn);
            $this->view->d_kd_kppn = $kppn;
        }
        if (Session::get('role') == SATKER) {
            $filter[$no++] = " a.kdsatker = '" . Session::get('kd_satker') . "'";
            $this->view->d_satker = Session::get('kd_satker');
        }
        
        //filter $post
        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdkanwil'] != '') {
                $filter[$no++] = "KDKANWIL = '" . $_POST['kdkanwil'] . "'";
                $d_kanwil = new DataUser($this->registry);
                $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$_POST['kdkanwil']);
                $this->view->d_kanwil = $_POST['kdkanwil'];
            }
            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KDKPPN = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
                $this->view->d_kd_kppn = $_POST['kdkppn'];
            }
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kdsatker = $_POST['kdsatker'];
            }
        }

			
        $this->view->data = $d_rpd->get_page5($filter);

        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpd5');
		$d_log->tambah_log("Sukses");
    }
    
    public function monitoringRPDKPPN() {
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;

        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
        
        $d_kppn = new DataUser($this->registry);
        $this->view->kppn_list = $d_kppn->get_kppn_kanwil();
        
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }
        
        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                if ($_POST['bulan'] != 'SEMUA_BULAN') {
                    $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                }
                $this->view->d_bulan = $_POST['bulan'];
            }
        } else {
            $filter[$no++] = "BULAN = '" . date('m', time()) . "'";
            //$filter[$no++] = "BULAN = '11'";
            $this->view->d_bulan = date('m', time());
        }
        
        
        //$this->view->jml_rek = $d_spm1->get_jml_rek_dep($_POST['kdkppn']);
        $this->view->data = $d_rpd->get_monitoring_rpd_bulan($filter);
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table1());

        $this->view->render('pkn/monitoringBulan');
        $d_log->tambah_log("Sukses");
    }

    public function rekapRPDAkurasiSatker($bulan=null,$satker=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }
        if (session::get('role') == SATKER) {
            $filter[$no++] = " KDSATKER = '" . Session::get('kd_satker') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_kd_satker = Session::get('kd_satker');
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->d_kdsatker = $_POST['kdsatker'];
            }
            $this->view->data = $d_rpd->get_rpd_satker($filter);
            $this->view->data_akun = $d_rpd->get_akun_satker($filter);
            $this->view->data_dom = $d_rpd->get_dom_satker($filter);
        }

        
        if(!is_null($bulan)&&!is_null($satker)){
            if(!is_null($bulan)){
                $filter[$no++] = "BULAN = '" . $bulan. "'";
                $this->view->d_bulan = $bulan;
            }
            if(!is_null($satker)){
                $filter[$no++] = "KDSATKER = '" . $satker . "'";
                $this->view->d_kdsatker = $satker;        
            }
            $this->view->data = $d_rpd->get_rpd_satker($filter);
            $this->view->data_akun = $d_rpd->get_akun_satker($filter);
            $this->view->data_dom = $d_rpd->get_dom_satker($filter);
        }
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table());
		
        $this->view->render('pkn/rpdSatker');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDAkurasiKPPN($bulan=null,$kdkppn=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }
        if (session::get('role') == KPPN) {
            $filter[$no++] = " KDKPPN = '" . Session::get('id_user') . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn(Session::get('id_user'));
                $this->view->d_kd_kppn = Session::get('id_user');
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KDKPPN = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
                $this->view->d_kd_kppn = $_POST['kdkppn'];
            }
            $this->view->data = $d_rpd->get_rpd_kppn($filter);
        }

        
        if(!is_null($bulan)&&!is_null($kdkppn)){
            if(!is_null($bulan)){
                $filter[$no++] = "BULAN = '" . $bulan. "'";
                $this->view->d_bulan = $bulan;
            }
            if(!is_null($kdkppn)){
                $filter[$no++] = "KDKPPN = '" . $kdkppn . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($kdkppn);
                $this->view->d_kd_kppn = $kdkppn;        
            }
            $this->view->data = $d_rpd->get_rpd_kppn($filter);
        }
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table()."_kppn_pvt");
		
        $this->view->render('pkn/rpdKPPN');
		$d_log->tambah_log("Sukses");
    }

    public function rekapRPDAkurasiKanwil($bulan=null,$kdkanwil=null) {   //nama function
        $d_rpd = new DataRPD($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (Session::get('role') == ADMIN OR Session::get('role') == PKN) {
            $d_kppn_list = new DataUser($this->registry);
            $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
            $this->view->kanwil_list = $d_kppn_list->get_kanwil();
        }
        if (Session::get('role') == KANWIL) {
            $d_kppn_list = new DataUser($this->registry);
            $kppn_list = $d_kppn_list->get_kppn_kanwil(Session::get('id_user'));
            $this->view->kppn_list = $kppn_list;
            $kppnya='';
            foreach ($kppn_list as $value1) {
                $kppnya .= "'".$value1->get_kd_d_kppn()."',";
            }
            $filter[$no++] = " kdkppn in (".$kppnya."'0') ";
        }

        if (isset($_POST['submit_file'])) {
            if ($_POST['bulan'] != '') {
                $filter[$no++] = "BULAN = '" . $_POST['bulan'] . "'";
                $this->view->d_bulan = $_POST['bulan'];
            }
            if ($_POST['kdkanwil'] != '') {
                $filter[$no++] = "KDKANWIL = '" . $_POST['kdkanwil'] . "'";
                $d_kanwil = new DataUser($this->registry);
                $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$_POST['kdkanwil']);
                $this->view->d_kanwil = $_POST['kdkanwil'];
            }
            $this->view->data = $d_rpd->get_rpd_kanwil($filter);
        }

        
        if(!is_null($bulan)&&!is_null($kdkanwil)){
            if(!is_null($bulan)){
                $filter[$no++] = "BULAN = '" . $bulan. "'";
                $this->view->d_bulan = $bulan;
            }
            if(!is_null($kdkanwil)){
                $filter[$no++] = "KDKANWIL = '" . $kdkanwil . "'";
                $d_kanwil = new DataUser($this->registry);
                $this->view->d_nama_kanwil = $d_kanwil->get_d_user_kppn("K".$kdkanwil);
                $this->view->d_kanwil = $kdkanwil;        
            }
            $this->view->data = $d_rpd->get_rpd_kanwil($filter);
        }
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_rpd->get_table()."_kanwil_pvt");
		
        $this->view->render('pkn/rpdKanwil');
		$d_log->tambah_log("Sukses");
    }
    
    public function __destruct() {
        
    }

}